home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Franz PD / Franz PD Disk #047 (1990)(Amiga User Group Deutschland e.V.)[v Disaster Master 2].zip / Franz PD Disk #047 (1990)(Amiga User Group Deutschland e.V.)[v Disaster Master 2].adf / A68K_Beispiele / say.asm < prev    next >
Assembly Source File  |  1989-07-02  |  7KB  |  279 lines

  1. ***************************************
  2. * say - speak a text file             *
  3. *                                     *
  4. * written by E. Lenz                  *
  5. *            Johann-Fichte-Strasse 11 *
  6. *            8 Munich 40              *
  7. *            Germany                  *
  8. *                                     *
  9. ***************************************
  10.  
  11. **** exec ****
  12.  
  13. _AbsExecBase     equ 4
  14. _LVOForbid       equ -$84
  15. _LVOPermit       equ -$8a
  16. _LVOAddPort      equ -$162
  17. _LVORemPort      equ -$168
  18. _LVOGetMsg       equ -$174
  19. _LVOReplyMsg     equ -$17a
  20. _LVOWaitPort     equ -$180
  21. _LVOCloseLibrary equ -$19e
  22. _LVOOpenDevice   equ -$1bc
  23. _LVOCloseDevice  equ -$1c2
  24. _LVODoIo         equ -$1c8
  25. _LVOOpenLibrary  equ -$228
  26.  
  27. **** dos *****
  28.  
  29. _LVOOpen     equ -$1e
  30. _LVOClose    equ -$24
  31. _LVORead     equ -$2a
  32. _LVOWrite    equ -$30
  33.  
  34. ***** translator ****
  35.  
  36. _LVOTranslate equ -$1e
  37.  
  38. TC_SIGRECVD      equ $1a
  39. pr_MsgPort       equ $5c
  40. pr_CLI           equ $ac
  41. ThisTask         equ $114
  42. VBlankFrequency  equ $212
  43. SIGBREAK_ANY     equ $1000
  44.  
  45.         XREF ReadLn,request
  46.        
  47.         code
  48.  
  49.         move.l  a0,d7             save instruction from CLI
  50.         move.l  d0,d4
  51.         subq.w  #1,d4
  52.         clr.b   0(a0,d4.w)
  53.  
  54.         movea.l _AbsExecBase,a6   test if WB or CLI
  55.         movea.l ThisTask(a6),a0
  56.         move.l  a0,writerep+$10
  57.         lea     TC_SIGRECVD(a0),a1  get task signal address
  58.         move.l  a1,TaskSigs
  59.  
  60.         moveq   #0,d0
  61.         tst.l   pr_CLI(a0)
  62.         bne.s   isCLI
  63.  
  64.         lea     pr_MsgPort(a0),a0        for WB get WB Message
  65.         jsr     _LVOWaitPort(a6)
  66.         jsr     _LVOGetMsg(a6)
  67.         moveq   #0,d4             make sure there's no instruction
  68.  
  69. isCLI   move.l  d0,-(a7)
  70.  
  71.         cmpi.b  #60,VBlankFrequency(a6) test if PAL or NTSC
  72.         beq.s   isNTSC
  73.         move.l  #'256/',window+12
  74.  
  75. isNTSC  lea     transname(pc),a1     open translator library
  76.         moveq   #0,d0
  77.         jsr     _LVOOpenLibrary(a6)
  78.         movea.l d0,a4
  79.         tst.l   d0           this is one of the few cases
  80.         bne.s   Transok      where this test is vital
  81.         lea     transname(pc),a0   first line
  82.         lea     notfnd(pc),a1     second line
  83.         suba.l  a2,a2             no third line
  84.         lea     hdtxt(pc),a3      header
  85.         lea     OkTxt(pc),a4      gadget text
  86.         suba.l  a5,a5             no 2nd gadget
  87.         jsr     request
  88.         suba.l  a3,a3
  89.         bra     nocon
  90.  
  91. Transok lea     dosname(pc),a1    open DOS library
  92.         moveq   #0,d0
  93.         jsr     _LVOOpenLibrary(a6)
  94.         movea.l d0,a3
  95.         tst.l   d0
  96.         beq.s   Gerror
  97.  
  98.         movea.l d0,a6             open Console window
  99.         move.l  #window,d1
  100.         move.l  #1005,d2
  101.         jsr     _LVOOpen(a6)
  102.         movea.l d0,a5
  103.         tst.l   d0
  104. Gerror  beq     error
  105.  
  106.         movea.l _AbsExecBase,a6 
  107.         lea     writerep(pc),a1
  108.         jsr     _LVOAddPort(a6)
  109.  
  110.         lea     talkio(pc),a1
  111.         moveq   #0,d0
  112.         moveq   #0,d1
  113.         lea     nardevice(pc),a0
  114.         jsr     _LVOOpenDevice(a6)
  115.         tst.l   d0
  116.         bne     exit
  117.  
  118.         movea.l a3,a6
  119.         move.l  d7,d1
  120.         tst.l   d4
  121.         bne.s   file
  122.  
  123.         move.l  a5,d1           request information
  124.         move.l  #FOB,d2         on what to do
  125.         moveq   #FOBE-FOB,d3
  126.         jsr     _LVOWrite(a6)
  127.  
  128.         move.l  a5,d1           Begin address
  129.         move.l  #filename,d2
  130.         moveq   #60,d3
  131.         jsr     _LVORead(a6)
  132.  
  133.         lea     filename(pc),a0
  134. loop    cmpi.b  #$a,(a0)+
  135.         bne.s   loop
  136.         clr.b   -1(a0) 
  137.  
  138.         move.l  #filename,d1      open old file
  139. file    move.l  #1005,d2
  140.         jsr     _LVOOpen(a6)
  141.         move.l  d0,filehandle
  142. Gexit   beq     exit
  143.  
  144.         lea     talkio(pc),a1
  145.         move.l  #writerep,14(a1)
  146.         move.w  #150,48(a1)      rate 40-400
  147.         move.w  #110,50(a1)      pitch 65-320
  148.         move.w  #0,52(a1)        mode  0-1
  149.         move.w  #0,54(a1)        sex   0-1
  150.         move.l  #amaps,56(a1)    masks
  151.         move.w  #4,60(a1)        4 masks
  152.         move.w  #64,62(a1)       volume
  153.         move.w  #22200,64(a1)
  154.  
  155. saylop  bsr     Read
  156.         move.l  d1,d4
  157.         beq.s   Gexit
  158.  
  159.         movea.l TaskSigs,a0      test for ***BREAK***
  160.         move.l  (a0),d0
  161.         andi.l  #SIGBREAK_ANY,d0
  162.         bne.s   Gexit
  163.  
  164.         lea     outtext(pc),a1 clear translated stuff
  165.         moveq   #0,d0
  166.         moveq   #$7f,d1
  167. clear   move.l  d0,(a1)+
  168.         dbra    d1,clear
  169.  
  170.         move.l  a1,a2          write to console
  171.         move.l  a5,d1
  172.         move.l  #Buffer,d2
  173.         move.l  d4,d3
  174.         jsr     _LVOWrite(a6)
  175.  
  176.         cmpi.l   #1,d4
  177.         beq.s    saylop
  178.  
  179.         move.l  d4,d0
  180.         clr.b   -1(a2)
  181.  
  182.         lea     Buffer(pc),a0
  183.         lea     outtext(pc),a1
  184.         move.l  #512,d1
  185.         movea.l a4,a6
  186.         jsr     _LVOTranslate(a6)
  187.  
  188.         lea     talkio(pc),a1
  189.         move.w  #3,28(a1)
  190.         move.l  #512,36(a1)
  191.         move.l  #outtext,40(a1)
  192.         move.l  _AbsExecBase,a6
  193.         jsr     _LVODoIo(a6)
  194.         bra     saylop
  195.  
  196. exit    move.l  _AbsExecBase,a6
  197.         lea     writerep(pc),a1
  198.         jsr     _LVORemPort(a6)
  199.  
  200.         lea     talkio(pc),a1
  201.         jsr     _LVOCloseDevice(a6)
  202.  
  203.         movea.l a4,a1               close translator library
  204.         jsr     _LVOCloseLibrary(a6)
  205.  
  206. error   move.l  a3,a6
  207.  
  208.         move.l  filehandle(pc),d1  close file
  209.         beq.s   nofile
  210.         jsr     _LVOClose(a6)
  211.  
  212. nofile  move.l  a5,d1            close console
  213.         beq.s   nocon
  214.         jsr     _LVOClose(a6)
  215.  
  216. nocon   move.l  _AbsExecBase,a6
  217.         move.l  (a7)+,d0
  218.         beq.s   NoBench
  219.         jsr     _LVOForbid(a6)    reply to WB
  220.         movea.l d0,a1
  221.         jsr     _LVOReplyMsg(a6)
  222.         jsr     _LVOPermit(a6)
  223.  
  224. NoBench move.l  a3,d0
  225.         beq.s   NoDos
  226.         movea.l d0,a1             close dos.lib
  227.         jsr     _LVOCloseLibrary(a6)
  228. NoDos   moveq   #0,d0
  229.         rts
  230.  
  231. Read    movem.l a2-a5,-(a7)
  232.         movea.l a3,a6
  233.         move.l  BufNum(pc),d0
  234.         movea.l BufPnt(pc),a0
  235.         movea.l #Buf2,a1
  236.         movea.l #Buffer,a2
  237.         movea.l filehandle(pc),a3
  238.         jsr     ReadLn
  239.         move.l  d0,BufNum
  240.         move.l  a0,BufPnt
  241.         movem.l (a7)+,a2-a5
  242.         rts
  243.  
  244. TaskSigs   ds.l 1
  245. amaps      dc.b 3,5,10,12
  246.  
  247. transname  dc.b 'translator.library',0
  248. dosname    dc.b 'dos.library',0
  249. nardevice  dc.b 'narrator.device',0
  250.            even
  251.  
  252. ; requester texts
  253.  
  254. notfnd     dc.b ' not found',0
  255. hdtxt      dc.b ' Say Request',0
  256. OkTxt      dc.b ' OK',0
  257.            even
  258.  
  259. FOB        dc.b 'Filename:'
  260. FOBE       even
  261. filename   ds.b 80
  262.  
  263. window     dc.b 'CON:0/0/639/199/Say',0
  264.            even
  265.  
  266.  
  267. filehandle dc.l 0
  268. narread    ds.l 20
  269. talkio     ds.l 20
  270. writerep   ds.l 8
  271. BufNum     dc.l 0
  272. BufPnt     dc.l 0
  273. Buffer     ds.b 200
  274. Buf2       ds.b 200
  275. outtext    ds.l $100
  276.            end
  277.  
  278.  
  279.